package top.soft.util;

import java.util.HashMap;
import java.util.Map;

import top.soft.bean.User;
import top.soft.windows.MainWindow;

/**
 * @ClassName: CommonData
 * @Author: Amosen
 * @Since: 2021/4/21
 */

// 程序的一些共享数据
public class CommonData {

	public static boolean isLogin = false;

	public static Integer FRAME_WIDTH = 600;

	public static Integer FRAME_HEIGHT = 600;

	public static final Integer BAR_COLUMNS = 15;

	public static final Integer BTN_WIDTH = 50;

	public static final Integer BTN_HEIGHT = 20;

	public static final String WINDOW_TITLE = "实验室资源管理系统";

	public static final String LOGIN_USERNAME = "用户名：";

	public static final String LOGIN_PASSWORD = "密  码：";

	public static final String RESET_PASSWORD = "请输入您的旧密码";

	public static final String RESET_NEW_PASSWORD = "请输入您的新密码";

	public static final String RESET_RE_PASSWORD = "请再输入一次您的新密码";

	public static final String LOGIN_BTN = "登录";

	public static final String REGISTER_BTN = "注册";

	public static final String SEARCH_BTN = "查找";

	public static final String CONFIRM_BTN = "提交";

	public static final String RESET_BTN = "重置";

	public static final String DELETE_BTN = "删除";

	public static final String REFRESH_BTN = "刷新";

	public static final String ADD_PROPERTY_ACCOUNT = "账户";

	public static final String ADD_PROPERTY_AUTH = "权限";

	public static final String CHOOSE_BTN = "选择文件";

	public static final String UPLOAD_BTN = "上传";

	public static final String DOWNLOAD_BTN = "下载";

	public static final String TAB_ONE = "成员信息";

	public static final String TAB_TWO = "添加成员";

	public static final String TAB_THREE = "修改密码";

	public static final String TAB_FOUR = "文件共享";

	public static final String TAB_FIVE = "实验室聊天";

	public static final String[] AUTH_SELECT_BOX = { "所有人", "管理员", "仅root用户" };

	public static Map<String, Integer> QUALIFICATION_MAP;

	public static final String BASE_DOMAIN = "http://localhost:8080/back";

	public static final String LOGIN_PATH = BASE_DOMAIN + "/user/login";

	public static final String REGISTER_PATH = BASE_DOMAIN + "/user/register";

	public static final String SEARCH_PATH = BASE_DOMAIN + "/user/search";

	public static final String GET_ALL_PATH = BASE_DOMAIN + "/user/get/all";

	public static final String UPDATE_PASSWORD_PATH = BASE_DOMAIN + "/user/update/password";

	public static final String ADD_USER_PATH = BASE_DOMAIN + "/user/add";

	public static final String DELETE_USER_PATH = BASE_DOMAIN + "/user/delete";

	public static final String FILE_LIST_PATH = BASE_DOMAIN + "/user/get/filelist";

	public static final String UPLOAD_FILE_PATH = BASE_DOMAIN + "/user/upload";

	public static final String DOWNLOAD_PATH = BASE_DOMAIN + "/user/download";

	public static final String WEBSOCKET_URI = "ws://localhost:8080/back/chat";

	public static final Integer COMMON_AUTH = 0;

	public static final Integer ROOT = 1;

	public static final Integer MANAGER = 2;

	public static final String CLASS_CAST_EXCEPTION_CODE = "001";

	public static final String[] TABLE_HEADER = { "账户", "身份" };

	public static final Integer TABLE_COLUMNS_NUM = 2;

	public static final String[] FILE_TABLE_HEADER = { "id", "文件名", "文件类型", "文件大小", "上传者", "下载次数", "下载权限" };

	public static final Integer FILE_TABLE_COLUMNS_NUM = 7;

	public static String[][] userData;

	public static String[][] fileData;

	private static User user = new User();

	// 观察者模式，数据中心持有唯一主题，便于观察者获取
	private static WebSocketClientImpl webSocketClient;

	private static MainWindow mainWindow;

	// 初始化权限map
	static {
		QUALIFICATION_MAP = new HashMap<>();
		QUALIFICATION_MAP.put("common", 0);
		QUALIFICATION_MAP.put("manager", 1);
		QUALIFICATION_MAP.put("root", 2);
	}

	public static User getUser() {
		return user;
	}

	public static void setUser(User user) {
		CommonData.user = user;
	}

	public static boolean isIsLogin() {
		return isLogin;
	}

	public static void setIsLogin(boolean isLogin) {
		CommonData.isLogin = isLogin;
	}

	public static void setWebSocketClient(WebSocketClientImpl wsc) {
		webSocketClient = wsc;
	}

	public static WebSocketClientImpl getWebSocketClient() {

		return webSocketClient;
	}

	public static void setMainWindow(MainWindow mw) {
		mainWindow = mw;
	}

	public static MainWindow getMainWindow() {
		return mainWindow;
	}
}
